import dataStore from './dataStore';
import axios from 'axios';

axios.defaults.baseURL = "http://localhost:4004";

// var newStore = {
//     dataStore : {}
// };

function fetchData(location){

    console.log('location: ', location);

    // console.log('url: ', url);
    var url = location.pathname == '/app/home' ? '/home' : '/about';

    return new Promise((resolve,reject)=>{

        axios.get(url).then(data=>{

            console.log('data: ', data.data);

            dataStore.initData(data.data);

            resolve(data.data);

        }).catch(err=>{

            reject(err);

        })

    })

}

export {
    fetchData 
}
